<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><ui:insert name="title">Default Title</ui:insert></title>
        <h:outputStylesheet library="css" name="jsfcrud.css"/>
    </h:head>

    <h:body>
        
        <div class="cabecera">
            <div class="logo">
                <h:link outcome="/index" >
                    <img border="0" src="#{resource['img/logo.png']}" width="35%" height="35%" />
                </h:link>
            </div>
            <div class="usuario">
                <h:form>
                <h:panelGrid columns="1" rendered="#{login.loggedIn}">
                    <h:form rendered="#{login.loggedInUser}">
                        <h2>Hola: #{login.usuario.nombreUsuario}</h2>
                    </h:form>
                    
                    <h:form rendered="#{login.loggedInAdmin}">
                        <h2>Hola #{login.admin.nombreAdmin}</h2>
                    </h:form>

                </h:panelGrid>
                <h:panelGrid columns="2" rendered="#{!login.loggedIn}">

                    <h:outputLabel for="username">Username:</h:outputLabel>

                    <h:inputText id="username" value="#{credenciales.username}"/>

                    <h:outputLabel for="password">Password:</h:outputLabel>

                    <h:inputSecret id="password" value="#{credenciales.password}"/>

                </h:panelGrid>

                <h:panelGrid columns="2">
                <h:commandButton value="Login" action="#{login.doLogin}" rendered="#{!login.loggedIn}"/>
                
                <h:commandButton value="Registrate" action="#{usuariosMainController.prepareCreate}" rendered="#{!login.loggedIn}"/>

                <h:commandButton value="Logout" action="#{login.logout}" rendered="#{login.loggedIn}"/>
                                
                <h:commandButton value="Perfil" action="#{usuariosMainController.prepareView()}" rendered="#{login.loggedInUser}"/>
                    
                <h:commandButton value="Panel Admin" action="/administrador/PanelAdmin" rendered="#{login.loggedInAdmin}"/>
                
                </h:panelGrid>

            </h:form>
            </div>
        </div>
        
        <div class="contenedor">
            <div class="cuerpo">
                <h1>
                    <ui:insert name="title">Default Title</ui:insert>
                </h1>
                <p>
                    <ui:insert name="body">Default Body</ui:insert>
                </p>
                
            </div>
        </div>
        
    </h:body>

</html>
